package com.xrc;

import java.util.Arrays;
import java.util.Scanner;

public class Progect {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] serialNumber = {1, 2, 3};//序号
        String[] menu = {"红烧带鱼", "鱼香肉丝", "时令鲜蔬"};
        double[] price = {38.0, 20.0, 10.0};
        String[] names = new String[5];//订餐人名字
        int[] xuhao = {3,4,5,6,7,8,9,10};//订餐序号
        int[] numbers = new int[5];//订餐数量
        int[] time = new int[5];//送餐时间
        String[] site = new String[5];//地址
        String[] state= {"预定","预定","预定"};//签收状态
        String[] state1= {"签收"};
        int[] zan=new int[5];//点赞

        System.out.println("欢迎使用“吃货联盟订餐系统”");
        boolean agains = true;
        int[] bian = new int[5];
        double[] sum = new double[5];
         int a;
        int index = 0;

        while (agains) {

            System.out.println("***********************");
            System.out.println("1、我要订餐\n" + "2、查看餐袋\n" + "3、签收订单\n" + "4、删除订单\n" + "5、我要点赞\n" + "6、退出系统");
            System.out.println("***********************");
            System.out.print("请选择：");
            int choice = sc.nextInt();

            switch (choice) {
                case 1:
                    System.out.println("***我要订餐***");
                    System.out.print("请输入订餐人姓名：");
                    names[index] = sc.next();
                    System.out.println("序号    菜名    单价");
                    for (int j = 0; j < serialNumber.length; j++) {
                        System.out.println(serialNumber[j] + "      " + menu[j] + "  " + price[j] + "元");
                    }
                    System.out.print("请选择你要点的菜品编号");
                    int bianhao = sc.nextInt();
                    bian[index] = bianhao - 1;
                    System.out.print("请选择你要的份数：");
                    numbers[index] = sc.nextInt();
                    //总金额
                    sum[index] = price[bianhao - 1] * numbers[index];
                    System.out.print("请输入送餐时间(10-12点之间)：");
                    time[index] = sc.nextInt();
                    if(time[index]<10||time[index]>12){
                        System.out.println("请输入10-12点之间");
                        continue;
                    }
                    System.out.print("请输入送餐地址：");
                    site[index] = sc.next();
                    System.out.println("订餐成功！\n" + "您订的是:" + menu[bianhao - 1] + numbers[index] + "份\n"
                            + "送餐时间是：" + time[index] + "点\n" + "餐费：" + sum[index] + "元，送餐费0元，总计" + sum[index] + "元");
                    index++;
                    System.out.print("输入0返回：");
                    a = sc.nextInt();
                    if (a == 0) {
                        agains = true;

                    } else {
                        agains = false;
                    }
                        break;

            case 2:
                   System.out.println("***查看餐袋***");
                   System.out.println("序号     订餐人     餐品信息      送餐地址    总金额    订单状态");
                   System.out.println("1        张强     红烧带鱼 2份  天成路207号  总金额76    已完成");
                   System.out.println("2        张强     鱼香肉丝 2份  天成路207号  总金额40    已预定");
                for (int i = 0; i < names.length; i++) {
                    if (names[i] == "" || names[i] == null){
                    }else
                    System.out.println(xuhao[i]+"      "+names[i]+"     "+menu[bian[i]]+"     "+numbers[i]+"     "+site[i]+"    "+"总金额"+sum[i]+"     "+state[i]);
                }
                System.out.print("输入0返回：");
                a = sc.nextInt();
                if (a == 0) {
                    agains = true;
                } else {
                    agains = false;
                }
                break;
               case 3:
                   System.out.println("***签收订单***");
                   System.out.print("请选择签收订单序号：");
                   int b=sc.nextInt();
                   for (int i = 0; i < xuhao.length; i++) {
                       if(b==xuhao[i]){
                           state[i]=state1[0];
                       }
                   }
                   System.out.print("输入0返回：");
                   a = sc.nextInt();
                   if (a == 0) {
                       agains = true;
                   } else {
                       agains = false;
                   }
                   break;
               case 4:
                   System.out.println("***删除订单***");
                   System.out.print("请选择要删除的订单：");
                   int c=sc.nextInt();
                   for (int i = 0; i < xuhao.length; i++) {
                       if(site[i]==state1[0]) {
                           if (c == xuhao[i]) {
                               names[i] = names[i + 1];
                               names[i + 1] = null;
                               menu[bian[i]] = menu[bian[i + 1]];
                               menu[bian[i + 1]] = null;
                               numbers[i] = numbers[i + 1];
                               numbers[i + 1] = 0;
                               site[i] = site[i + 1];
                               site[i + 1] = null;
                               sum[i] = sum[i + 1];
                               sum[i + 1] = 0;
                               state[i] = state[i + 1];
                               state[i + 1] = null;
                           }
                       }else {
                           System.out.println("订单未签收");
                       }
                   }
                   System.out.print("输入0返回：");
                   a = sc.nextInt();
                   if (a == 0) {
                       agains = true;
                   } else {
                       agains = false;
                   }
                   break;
               case 5:
                   System.out.println("***我要点赞***");
                   System.out.println("序号    菜名    单价");
                   for (int j = 0; j < serialNumber.length; j++) {
                       System.out.println(serialNumber[j] + "      " + menu[j] + "  " + price[j] + "元"+"  "+zan[j]+"赞");
                   }
                   System.out.print("请选择你要点赞的菜品序号：");
                   int num=sc.nextInt();
                   zan[num-1]=zan[num-1]+1;
                   System.out.print("输入0返回：");
                   a = sc.nextInt();
                   if (a == 0) {
                       agains = true;
                   } else {
                       agains = false;
                   }
                   break;
               case 6:
                   System.out.println("谢谢使用，欢迎下次光临");
                   agains=false;
                   break;

                }


            }

        }
    }
